<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="manageWarehouses" binding="#{warehouseManagerBean.loadManageWarehouses}">
                    <p:panel header="Warehouses" id="warehousesPanel">
                        <p:messages />
                        
                        <p:dataTable id="warehouses" var="warehouse" value="#{warehouseManagerBean.warehouses}" selectionMode="single" 
                                     selection="#{warehouseManagerBean.selectedWarehouse}" paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
                            <p:column filterBy="#{warehouse.id}" headerText="Warehouse Id" filterMatchMode="contains">  
                                <h:outputText value="#{warehouse.id}" />  
                            </p:column> 
                            <p:column filterBy="#{warehouse.productionBatches.size()}" headerText="No. of Production Batches" filterMatchMode="contains">  
                                <h:outputText value="#{warehouse.productionBatches.size()}" />  
                            </p:column> 
                            <p:column filterBy="#{warehouse.rawMaterialDeliveries.size()}" headerText="No. of Raw Material Deliveries" filterMatchMode="contains">  
                                <h:outputText value="#{warehouse.rawMaterialDeliveries.size()}" />  
                            </p:column>
                            <p:column filterBy="#{warehouse.warehouseZones.size()}" headerText="No. of Zones" filterMatchMode="contains">  
                                <h:outputText value="#{warehouse.warehouseZones.size()}" >
                                </h:outputText>
                            </p:column>
                        </p:dataTable>
                        <table class="table-submit">
                            <tr>
                                <td align="center">
                                    <p:commandButton id="btnUpdateAWarehouse" value="Update Warehouse"
                                                     title="Update the selected warehouse." ajax="true"
                                                     update="warehousesPanel"
                                                     actionListener="#{warehouseManagerBean.updateWarehouse}" />
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
